
#ifndef __TFTP_H__
#define __TFTP_H__

/*******************************************
 *	tftp define.
 ********************************************/


#define TFTP_PORT		69

#define ERROR -1

#define RRQ 1
#define WRQ 2
#define DATA 3
#define ACK 0x04
#define ERR 0x05

#define TIMEOUT 2000 /*amount of time to wait for an ACK/Data Packet in 1000microseconds 1000 = 1 second*/
#define RETRIES 3 /* Number of times to resend a data OR ack packet beforing giving up */
#define MAXACKFREQ 16 /* Maximum number of packets before ack */
#define MAXDATASIZE 1024 /* Maximum data size allowed */


///Request packet header
typedef struct{
	UNS16 opcode;
	UNS8 *filename;
	UNS8 *mode;
}REQUEST_HEADER;


///DATA packet header
typedef struct{
	UNS16 opcode;
	UNS16 block;
	UNS8 *data;
}DATA_HEADER;

#define DATA_PACKET_HEADER_SIZE 4

///ASK packet header
typedef struct{
	UNS16 opcode;
	UNS16 block;
}ASK_HEADER;

#define ASK_PACKET_SIZE	4

///ERROR packet header
typedef struct{
	UNS16 opcode;
	UNS16 errorcode;
	UNS8 *errmsg;
}ERROR_HEADER;




#endif /* __TFTP_H__ */




